package top.huxy.boot.model.dto;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

/**
 * @Classname Pagination
 * @Description Pagination
 * @Date 2021/8/30 20:37
 * @Created by huxy
 */
@ToString
@Getter
@EqualsAndHashCode
public class Pager {

    /**
     * 页码。从1开始，小于1则默认为1
     */
    private int page;

    /**
     * 每页数量。小于1则默认为1
     * <p>
     * 规定：不管什么情况，最大pageSize=300
     */
    private int pageSize;

    public Pager(int page, int pageSize) {
        if (page < 1) page = 1;
        this.page = page;

        if (pageSize < 1) pageSize = 1;
        this.pageSize = pageSize;

        if (pageSize > 300) pageSize = 300;
    }
}
